<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets" 
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core" 
	xmlns:c="http://java.sun.com/jstl/core"
	xmlns:rich="http://richfaces.ajax4jsf.org/rich" 
	xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
	xmlns:t="https://code.google.com/p/rad-framework/taglib" 
	xmlns:tt="https://code.google.com/p/rad-framework"
	xmlns:s="http://jboss.com/products/seam/taglib">

	<rich:simpleTogglePanel id="myFilterTP"
		switchType="ajax" label="#{messages['MyFilters']}" opened="false" style="width:192px"
		styleClass="rad-framework-myfilter-panel-bullets">

		<f:facet name="openMarker">
			<h:graphicImage value="/themes/default/images/rich-panel-header-max.gif">
			</h:graphicImage>
		</f:facet>
		<f:facet name="closeMarker">
			<h:graphicImage value="/themes/default/images/rich-panel-header-min.gif">
			</h:graphicImage>
		</f:facet>

		<ul>
			<ui:repeat value="#{myFilters.list(finder)}" var="savedFilter">
				<tt:sidebar-item>
					<table width="100%">
						<tr>
							<td>
								<a4j:commandLink action="#{myFilters.select(savedFilter.id)}"
									eventsQueue="viewQ"
									reRender="filterTP,searchTable,pagingGrid,quickSearchForm,filterName"
									value="#{savedFilter.name}">
								</a4j:commandLink>
							</td>
							<td align="right">
								<a4j:commandLink action="#{myFilters.remove(savedFilter.id)}"
									eventsQueue="viewQ" reRender="myFilterTP"
									onclick="if (!confirm('#{messages['DeleteConfirmation']}')) return false">
									<h:graphicImage
										value="/themes/default/images/icons/ico-sprite-delete.png" />
								</a4j:commandLink>
							</td>
						</tr>
					</table>
				</tt:sidebar-item>
			</ui:repeat>
		</ul>

		<rich:spacer width="1" height="1" />
		<hr class="rad-framework-horizontal-separator" />
		<rich:spacer width="1" height="1" />

		<tt:toggle-popup id="saveFilterToggle">

			<ui:define name="closed">
			
				<h:panelGroup style="align:right">
					<h:graphicImage value="/themes/default/images/icons/ico-sprite-save.png" />
					<rich:spacer width="5" height="1" />
					<rich:toggleControl for="saveFilterToggle"
						value="#{messages['OpenSaveFilter']}" />
				</h:panelGroup>
			
			</ui:define>

			<ui:define name="open">
			
				<t:fieldset legend="#{messages['SaveFilter']}">
					<h:panelGrid>
						<h:outputText value="#{messages['Name']}: " />
						<h:inputText id="filterName" value="#{finder.filter.name}"
							styleClass="rad-framework-form-input-field" />
						<h:panelGroup>
							<a4j:commandLink id="saveFilterBtn" action="#{myFilters.save(finder)}"
								eventsQueue="viewQ" reRender="sidebarForm" styleClass="rad-framework-button-left">
								<span>
									<h:outputText value="#{messages['Save']}" />
								</span>
							</a4j:commandLink>
							<rich:toggleControl for="saveFilterToggle"
								value="#{messages['Hide']}" />
							<h:outputText value=" | " />
							<a4j:commandLink id="clearFilter2" action="#{finder.clearFilter}"
								eventsQueue="viewQ" reRender="filterTP,filterName" value="#{messages['Clear']}" />
						</h:panelGroup>
					</h:panelGrid>
				</t:fieldset>
			
			</ui:define>

		</tt:toggle-popup>

	</rich:simpleTogglePanel>

</ui:composition>